package com.ts.main.mini.service;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ts.common.dto.FileDto;
import com.ts.main.mini.entity.FileEntity;
import com.ts.main.mini.mapper.FileMapper;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lk
 * @date 2024/2/22 17:38
 */
@AllArgsConstructor
@Service
public class FileServiceImpl extends ServiceImpl<FileMapper, FileEntity> {

  public FileDto addGoodsFile(FileDto dto) {
    FileEntity entity = new FileEntity();
    BeanUtils.copyProperties(dto, entity);
    save(entity);
    return dto;
  }

  public List<FileDto> addGoodsListFile(List<FileDto> dtos) {
    List<FileEntity> list = BeanUtil.copyToList(dtos, FileEntity.class);
    saveBatch(list);
    return dtos;
  }
}
